package com.ltf.product.controller;

import com.ltf.common.dto.ResponseDTO;
import com.ltf.product.pojo.ProductInfo;
import com.ltf.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.TimeUnit;

/**
 * @Auther: liutf
 * @Date: 2025/3/24
 * @Description: com.ltf.product.controller
 * @version: 1.0
 */

//@RequestMapping("/api/product")
@RefreshScope
@RestController
public class ProductController {

    @Autowired
    ProductService productService;

    @GetMapping("/getProduct")
    public ResponseDTO getProduct(@RequestParam("id") Long productId) throws InterruptedException {
        ProductInfo info = productService.getById(productId);
        return ResponseDTO.success(info);
    }

    @GetMapping("/getAllProduct")
    public ResponseDTO getAllProduct() {
        return ResponseDTO.success(productService.list());
    }
}
